import { defineStore } from "pinia";
import { ref } from "vue";

export const useUserStore=defineStore('user',()=>{
	//定义token
	const user=ref({})
	//保存token
	const setStore=(val)=>{
		user.value=val
	}
	//删除token
	const clearStore=()=>{
		user.value=''
	}
	//保存跳转地址
	const redirectURL=ref('/pages/task/index')
	//保存跳转方式
	const openType=ref('switchTab')
	return {
		user,
		setStore,
		clearStore,
		redirectURL,
		openType
	}
},
{
	//持久化
	persist:{
		storage:{
			setItem:(key,val)=>{
				uni.setStorageSync(key,val)
			},
			getItem:(key)=>{
				return uni.getStorageSync(key)
			}
		}
	}
}
)